﻿@model IEnumerable<eBusiness.Models.Product>
<table class="dashboardTable">
    <tr>
        <th style="width: 200px">
            Name
        </th>
        <th>
            Code
        </th>
        <th>
            Categories
        </th>
        <th>
            Type
        </th>
        <th>
            Price
        </th>
        <th>
            CreatedBy
        </th>
        <th>
            CreatedDate
        </th>
        <th>
            IsHot
        </th>
        <th>
            IsHome
        </th>
        <th>
            Status
        </th>
        <th>
            IsApproved
        </th>
        <th>
            IsDiscount
        </th>
        <th>
            Quantity
        </th>
    </tr>
    @foreach (var item in Model)
    {
        @Html.HiddenFor(modelItem => item.ID)
        <tr>
            <td  style="width: 200px">
                <a href='@Url.Action("Details", "Products", new { id = @item.ID })'>@Html.DisplayFor(modelItem => item.Name)</a>
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Code)
            </td>
            <td>
                @foreach (var cate in item.Categories)
                {
                    <a href='@Url.Action("Details", "Categories", new { id = @cate.ID })'>@Html.DisplayFor(modelItem => cate.Name)</a> @:,
                                }
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Type)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Price)
            </td>
            <td>
                @*@Html.DisplayFor(modelItem => item.CreatedBy)*@
                @if (item.CreatedBy != null)
                {
                    var membershipUser = Membership.GetUser(item.CreatedBy);
                    {
                        if (membershipUser != null)
                        {
                            @membershipUser.UserName
                        }
                    }
                }
            </td>
            <td>
                @if (item.CreatedDate != null && !string.IsNullOrEmpty(@item.CreatedDate.Value.ToString()))
                            {
                                @item.CreatedDate.Value.ToString("dd/MM/yyyy")
                            }
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.IsHot)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.IsHomepage)
            </td>
            <td>
                <a href="@Url.Action("Details", "Status", new { id = @item.StatusID })">@Html.DisplayFor(modelItem => item.Status.Name)</a>
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.IsApproved)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.IsDiscount)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.QuantityInStock)
            </td>
        </tr>
    }
</table>
